package com.yhy.wxzn.wcs.entity;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yhy.wxzn.wcs.device.rgv.enums.PriorityCodes;
import com.yhy.wxzn.wcs.device.rgv.enums.RgvProgress;
import com.yhy.wxzn.wcs.enums.RgvTaskAssignStatus;
import com.yhy.wxzn.wcs.enums.TaskStatus;
import com.yhy.wxzn.wcs.enums.TaskType;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @Description: 四向车任务表
 * @Author: jeecg-boot
 * @Date:   2023-11-08
 * @Version: V1.0
 */
@Data
@TableName("wcs_four_way_task")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="wcs_four_way_task对象", description="四向车任务表")
public class WcsFourWayTask implements Serializable {
    private static final long serialVersionUID = 1L;

	/**主键*/
	@TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "主键")
    private Integer id;

	/**业务单据号*/
	@Excel(name = "业务单据号", width = 15)
    @ApiModelProperty(value = "业务单据号")
    private String relateCode;
	/**任务状态*/
	@Excel(name = "任务状态", width = 15)
    @ApiModelProperty(value = "任务状态")
    private TaskStatus taskStatus;
	/**托盘号*/
	@Excel(name = "托盘号", width = 15)
    @ApiModelProperty(value = "托盘号")
    private String palletNo;
	/**起点*/
	@Excel(name = "起点", width = 15)
    @ApiModelProperty(value = "起点")
    private String source;
	/**终点*/
	@Excel(name = "终点", width = 15)
    @ApiModelProperty(value = "终点")
    private String target;
	/**优先级*/
	@Excel(name = "优先级", width = 15)
    @ApiModelProperty(value = "优先级")
    private Integer priority;
	/**任务类型*/
	@Excel(name = "任务类型", width = 15)
    @ApiModelProperty(value = "任务类型")
    private TaskType taskType;

	//是否分车 0未分配  1已分配
	private RgvTaskAssignStatus assignStatus;
	//处理当前任务的小车设备码
	private Integer processRgvDeviceCode;
	//任务进度
    private RgvProgress rgvProgress;

    /**创建日期*/
    @ApiModelProperty(value = "创建日期")
    private Date createTime;
    /**更新日期*/
    @ApiModelProperty(value = "更新日期")
    private Date updateTime;



    private static WcsFourWayTask buildTask(TaskType type,int rgvId,String start,String end){
        WcsFourWayTask task = new WcsFourWayTask();
        task.setTaskType(type);
        task.setProcessRgvDeviceCode(rgvId);
        task.setAssignStatus(RgvTaskAssignStatus.ASSIGNED);
        task.setRgvProgress(RgvProgress.ASSIGNED_TO_RGV);
        task.setTaskStatus(TaskStatus.READY);
        task.setSource(start);
        task.setTarget(end);
        return task;
    }

    public static WcsFourWayTask buildManualTask(TaskType type,int rgvId,String start,String end){
        WcsFourWayTask fourWayTask = buildTask(type, rgvId, start, end);
        fourWayTask.setPriority(PriorityCodes.MANUAL);
        return fourWayTask;
    }

    public static WcsFourWayTask buildAvoidTask(TaskType type,int rgvId,String start,String end){
        WcsFourWayTask fourWayTask = buildTask(type, rgvId, start, end);
        fourWayTask.setPriority(PriorityCodes.AVOID);
        return fourWayTask;
    }


}
